<template>
	<view class="enterPay">
		<view class="card" style="height: 200rpx;">
			<view class="oneLine between" v-show="referralCode==''">
				<view>商家入驻费用</view>
				<view style="color:#F40E0E">{{enterMoney}}元</view>
			</view>
			<view class="oneLine between">
				<view>商家保证金</view>
				<view style="color:#F40E0E">{{guaranteeMoney}}元</view>
			</view>
		</view>
		<view class="card" style="margin-bottom: 30rpx;">
			<view class="oneLine between">
				<view>推荐码</view>
				<view>
					<input placeholder="请输入推荐码" v-model="referralCode" placeholder-style="color:#B3B3B3;" />
				</view>
			</view>
		</view>
		<view class="hint"><text>*</text>如有推荐码入驻费为0元</view>
		<view class="submitBtn flex" @click="submit">确认支付</view>
	</view>
</template>

<script>
	import {
		setJoinMsg,
		getFranchiseFee,
		getPersonalCenter,
	} from "../../api/index.js"
	import {
		hex_md5
	} from "../../utils/md5.js";
	export default {
		data() {
			return {
				// 推荐码
				referralCode: '',
				// 商家入驻费用
				enterMoney: '',
				// 保证金
				guaranteeMoney: '',
			}
		},
		onLoad(opt) {
			this.onGetFranchiseFee()
			this.msg = JSON.parse(decodeURIComponent(opt.msg));
		},
		methods: {
			// 提交数据
			async submit() {
				this.msg.activation_code = this.referralCode
				const res = await setJoinMsg('s=/ApiMy/levelup', this.msg)
				console.log(res, "res---")
				const {
					money,
					payorderid,
					msg,
					status
				} = res.data
				this.showToast(msg)
				if (status == 1) {
					setTimeout(() => {
						this.referralCode != '' ?
							this.gotoJinJian() :
							this.onSkip(
								`/business/pages/business_tab/orderPay?money=${money}&orderId=${payorderid}&pageType=join`
							)
					}, 1500)
				}
			},
			async gotoJinJian() {
				this.onSkip(`/package/mine/jinjian`)
			},
			async onGetFranchiseFee() {
				const res = await getFranchiseFee('s=/ApiZwyRequest/businessfee&levelid=3')
				const {
					data,
					status,
					msg
				} = res.data
				if (status == 1) {
					// console.log(data,"data")
					this.enterMoney = data.apply_paymoney
					this.guaranteeMoney = data.apply_ensuremoney
				} else {
					this.showToast(msg)
				}

			},
		}
	}
</script>

<style lang="scss" scoped>
	input {
		// direction: rtl;
		text-align: right;
	}

	.hint {
		color: #999;
		font-size: 28rpx;
		margin-bottom: 80rpx;

		text {
			color: #F40E2A;
		}
	}

	.card {
		font-size: 36rpx;
		background: #fff;
		border-radius: 30rpx;
		font-weight: 500;
		margin-bottom: 75rpx;

		.oneLine {
			padding: 25rpx 30rpx;
		}

	}

	.enterPay {
		background: #F7F7F7;
		min-height: 87vh;
		padding: 30rpx 30rpx;
	}

	.submitBtn {
		margin-top: 10vh;
		color: #fff;
		font-size: 34rpx;
		background: #41644A;
		border-radius: 14rpx;
		padding: 20rpx 0;
		justify-content: center;
	}
</style>